package cn.itsource.basic.other.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 声明这是mvc的配置类，替换之前xml文件
 * 1.注册拦截器
 */
@Configuration
public class PetHomeMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //1.注册拦截器
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有的路径
                .excludePathPatterns("/**/login","/file/**","/shop/settlement","/pay/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**") //放行swagger
                .excludePathPatterns("/wechat/**","/error","/user/sendmobilecode"); //释放微信接口

    }
}
